/**
 * @author Putu Adhi Kerta Mahendra 5104 100 089
 * copyright(C) -  Mei 2008
 * Jurusan Teknik Informatika - ITS Surabaya
 */

package com.stemaini.core.database;


import com.stemaini.core.doc.*;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashSet;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.stemaini.utility.Koneksi;
import taini.koneksi.KoneksiAini;
import taini.query;

/**
 *
 * @author AdhiK
 */
public class StopList {
    private Set stopword;           //kata-kata yg termasuk dlm stoplist
    private KoneksiAini theKoneksi; //kelas koneksi ke database
    
    public StopList(KoneksiAini theKoneksi) {
        stopword = new HashSet();
        this.theKoneksi = theKoneksi;
        initialize();
    }
    
    public void initialize()
    {
        //if(theKoneksi.isConnected())
        {
            try {
                //ResultSet rset = theKoneksi.executeSelect("SELECT * FROM STOPLIST");
                ResultSet rset = new query().executeSQL("SELECT * FROM STOPLIST");
                if (rset.next()){
                    while (!rset.isAfterLast()) {
                        stopword.add(rset.getString("STOPWORD"));
                        rset.next();
                    }
                }
            } catch (SQLException ex) {
                Logger.getLogger(Dokumen.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IllegalStateException ex) {
                Logger.getLogger(Dokumen.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
    
    public boolean isContain(String str)
    {
        if(stopword.contains(str))
            return true;
        return false;
    }
    
    public int size()
    {
        return stopword.size();
    }
    
}
